package main

import (
    gomail "gopkg.in/gomail.v2"
)

func main() {

    msg := gomail.NewMessage()
    msg.SetHeader("From", "发送邮箱")
    msg.SetHeader("To", "对方邮箱")
    msg.SetHeader("Subject", "测试邮件")
    msg.SetBody("text/html", "<b>This is the body of the mail</b>")
    // msg.Attach("/home/User/cat.jpg")

    n := gomail.NewDialer("smtp.163.com", 465, "邮箱用户名", "授权码")

    // Send the email
    if err := n.DialAndSend(msg); err != nil {
        panic(err)
    }
}
